<!--
  Copyright © 2016 Cask Data, Inc.

  Licensed under the Apache License, Version 2.0 (the "License"); you may not
  use this file except in compliance with the License. You may obtain a copy of
  the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  License for the specific language governing permissions and limitations under
  the License.
-->

<h3>
  <span>Configuration</span>
  <button class="btn btn-default pull-right"
          ng-if="!IntegrationsController.navigatorSetup.popoverEnabled && IntegrationsController.navigatorState.status !== 'RUNNING'"
          ng-click="IntegrationsController.editConfiguration($event)">
    Edit
  </button>
</h3>
<form name="navigatorConfiguration" class="form-horizontal">
  <fieldset ng-disabled="!IntegrationsController.navigatorSetup.popoverEnabled">
    <h4>
      Cloudera
    </h4>
    <div class="form-group">
      <label class="control-label col-xs-4">Hostname</label>
      <div class="col-xs-8">
        <input type="text" class="form-control"
               ng-model="IntegrationsController.navigatorInfo.navigatorConfig.navigatorHostName"
               required>
      </div>
    </div>

    <div class="form-group">
      <label class="control-label col-xs-4">Username</label>
      <div class="col-xs-8">
        <input type="text" class="form-control"
               ng-model="IntegrationsController.navigatorInfo.navigatorConfig.username"
               required>
      </div>
    </div>

    <div class="form-group">
      <label class="control-label col-xs-4">Password</label>
      <div class="col-xs-8">
        <input type="password" class="form-control"
               ng-model="IntegrationsController.navigatorInfo.navigatorConfig.password"
               required>
      </div>
    </div>

    <h5 class="optional-settings-toggle"
        ng-click="IntegrationsController.optionalSettings.navigator = !IntegrationsController.optionalSettings.navigator">
      <span class="fa fa-caret-right"
            ng-if="!IntegrationsController.optionalSettings.navigator">
      </span>
      <span class="fa fa-caret-down"
            ng-if="IntegrationsController.optionalSettings.navigator">
      </span>
      <span>Optional Settings</span>
    </h5>

    <div ng-if="IntegrationsController.optionalSettings.navigator">
      <div class="form-group">
        <label class="control-label col-xs-4">Navigator Port</label>
        <div class="col-xs-8">
          <input type="text" class="form-control"
                 ng-model="IntegrationsController.navigatorInfo.navigatorConfig.navigatorPort">
        </div>
      </div>

      <div class="form-group">
        <label class="control-label col-xs-4">Auto Commit</label>
        <div class="col-xs-8">
          <input type="text" class="form-control"
                 ng-model="IntegrationsController.navigatorInfo.navigatorConfig.autocommit">
        </div>
      </div>

      <div class="form-group">
        <label class="control-label col-xs-4">Namespace</label>
        <div class="col-xs-8">
          <input type="text" class="form-control"
                 ng-model="IntegrationsController.navigatorInfo.navigatorConfig.namespace">
        </div>
      </div>

      <div class="form-group">
        <label class="control-label col-xs-4">Application URL</label>
        <div class="col-xs-8">
          <input type="text" class="form-control"
                 ng-model="IntegrationsController.navigatorInfo.navigatorConfig.applicationURL">
        </div>
      </div>

      <div class="form-group">
        <label class="control-label col-xs-4">File Format</label>
        <div class="col-xs-8">
          <input type="text" class="form-control"
                 ng-model="IntegrationsController.navigatorInfo.navigatorConfig.fileFormat">
        </div>
      </div>

      <div class="form-group">
        <label class="control-label col-xs-4">Navigator URL</label>
        <div class="col-xs-8">
          <input type="text" class="form-control"
                 ng-model="IntegrationsController.navigatorInfo.navigatorConfig.navigatorURL">
        </div>
      </div>

      <div class="form-group">
        <label class="control-label col-xs-4">Metadata Parent URI</label>
        <div class="col-xs-8">
          <input type="text" class="form-control"
                 ng-model="IntegrationsController.navigatorInfo.navigatorConfig.metadataParentURI">
        </div>
      </div>

    </div>

    <h4>
      Kafka
    </h4>
    <div class="form-group">
      <label class="control-label col-xs-4">Zookeeper String</label>
      <div class="col-xs-8">
        <input type="text" class="form-control"
               ng-model="IntegrationsController.navigatorInfo.metadataKafkaConfig.zookeeperString"
               required>
      </div>
    </div>

    <h5 class="optional-settings-toggle"
        ng-click="IntegrationsController.optionalSettings.kafka = !IntegrationsController.optionalSettings.kafka">
      <span class="fa fa-caret-right"
            ng-if="!IntegrationsController.optionalSettings.kafka">
      </span>
      <span class="fa fa-caret-down"
            ng-if="IntegrationsController.optionalSettings.kafka">
      </span>
      <span>Optional Settings</span>
    </h5>

    <div ng-if="IntegrationsController.optionalSettings.kafka">
      <div class="form-group">
        <label class="control-label col-xs-4">Topic</label>
        <div class="col-xs-8">
          <input type="text" class="form-control"
                 ng-model="IntegrationsController.navigatorInfo.metadataKafkaConfig.topic">
        </div>
      </div>

      <div class="form-group">
        <label class="control-label col-xs-4">Num Partitions</label>
        <div class="col-xs-8">
          <input type="text" class="form-control"
                 ng-model="IntegrationsController.navigatorInfo.metadataKafkaConfig.zookeeperString.numPartitions">
        </div>
      </div>

      <div class="form-group">
        <label class="control-label col-xs-4">Offset Dataset</label>
        <div class="col-xs-8">
          <input type="text" class="form-control"
                 ng-model="IntegrationsController.navigatorInfo.metadataKafkaConfig.zookeeperString.offsetDataset">
        </div>
      </div>
    </div>
  </fieldset>

  <div ng-if="IntegrationsController.navigatorSetup.popoverEnabled">
    <button class="btn btn-default pull-left"
            ng-disabled="IntegrationsController.saving"
            ng-click="IntegrationsController.cancelSetup()">
      Cancel
    </button>
    <button class="btn btn-success pull-right"
            ng-disabled="navigatorConfiguration.$invalid || IntegrationsController.saving"
            ng-click="IntegrationsController.saveNavigatorSetup()">
      <span ng-if="!IntegrationsController.saving">Save</span>
      <span ng-if="IntegrationsController.saving">
        <span class="fa fa-spin fa-refresh"></span>
        <span>Saving</span>
      </span>
    </button>
  </div>

</form>
